﻿using System;
using System.Collections;
using System.Text;
using System.Configuration;
using System.Xml;

namespace Sukul.PhotoTools.BL.Configuration
{
    public class MediaConfigSection : ConfigurationSection
    {
        // Create a "sourcefolder" attribute.
        [ConfigurationProperty("sourcefolder", DefaultValue = @"c:\", IsRequired = false)]
        public string SourceFolder
        {
            get
            {
                return (string)this["sourcefolder"];
            }
            set
            {
                this["sourcefolder"] = value;
            }
        }


        // Create a "PhotoDestinationFolder" attribute.
        [ConfigurationProperty("photodestinationfolder", DefaultValue = @"c:\", IsRequired = false)]
        public string PhotoDestinationFolder
        {
            get
            {
                return (string)this["photodestinationfolder"];
            }
            set
            {
                this["photodestinationfolder"] = value;
            }
        }

        // Create a "VideoDestinationFolder" attribute.
        [ConfigurationProperty("videodestinationfolder", DefaultValue = @"c:\", IsRequired = false)]
        public string VideoDestinationFolder
        {
            get
            {
                return (string)this["videodestinationfolder"];
            }
            set
            {
                this["videodestinationfolder"] = value;
            }
        }

        // Create a "photo" element.
        [ConfigurationProperty("photo")]
        public PhotoElement Photo
        {
            get
            {
                return (PhotoElement)this["photo"];
            }
            set
            { this["photo"] = value; }
        }

        // Create a "video" element.
        [ConfigurationProperty("video")]
        public VideoElement Video
        {
            get
            {
                return (VideoElement)this["video"];
            }
            set
            { 
                this["video"] = value; 
            }
        }
    }

    public class PhotoElement : ConfigurationElement
    {
        [ConfigurationProperty("filter", DefaultValue = "gif|png|jpg", IsRequired = true)]
        [StringValidator(InvalidCharacters = "~!@#$%^&*()[]{}/;'\"\\", MinLength = 1, MaxLength = 355)]
        public String Filter
        {
            get
            {
                return (String)this["filter"];
            }
            set
            {
                this["filter"] = value;
            }
        }
    }

    public class VideoElement : ConfigurationElement
    {
        [ConfigurationProperty("filter", DefaultValue = "wmv|avi", IsRequired = true)]
        [StringValidator(InvalidCharacters = "~!@#$%^&*()[]{}/;'\"\\", MinLength = 1, MaxLength = 355)]
        public String Filter
        {
            get
            {
                return (String)this["filter"];
            }
            set
            {
                this["filter"] = value;
            }
        }
    }
}
